<template>
  <div class="ke">
    <!-- <div class="powertop">
      <router-link class="powertopli powertopact" to="/yongjinzhichu/zhichuguanli" v-if="checkquanxian('V0201').length > 0">支出订单管理</router-link>
      <router-link class="powertopli " to="/yongjinzhichu/yongjinzhichu" v-if="checkquanxian('V0202').length > 0">佣金支出</router-link>
      <router-link class="powertopli " to="/yongjinzhichu/zhichudakuanshenhe" v-if="peizhi.second_commission_examine && checkquanxian('V0204').length > 0">支出审核</router-link>
      <router-link class="powertopli " to="/yongjinzhichu/zhichudakuan" v-if="checkquanxian('V0203').length > 0">支出打款</router-link>

     <router-link class="powertopli" to="/yongjinzhichu/zhichupeizhi"  v-if="zhichupeizhi">支出配置</router-link>
     <router-link class="powertopli " to="/yongjinzhichu/yongjinzhichubaobiao" v-if="checkquanxian('V0205').length > 0">佣金支出报表</router-link>
    </div> -->
    <top2></top2>
    <div v-loading='loading' style="padding: 20px;">

      <div class="kflexbc" style="margin-bottom: 20px;">
        <div class="kflexc" >
          <div class="lia" @click="changepay(0)" :class="all.is_already_pay == 0?'acts':''" >待支出</div>
          <div class="lia" @click="changepay(1)" :class="all.is_already_pay == 1?'acts':''" >已支出</div>
        </div>
      </div>

      <div class="kflexc" style="margin-bottom: 20px;" v-if="all.is_already_pay == 0">
        <el-button type="danger" round  plain style="margin-right: 20px; " @click="hesuandangqian()" :disabled="loading2" v-if="is_accounting == 0">核算当前佣金</el-button>
        <div style="margin-right: 20px;" v-if="is_accounting == 1">核算中</div>

        <div style="color: rgb(189, 189, 189);">上次核算时间：{{hesuanshijian}}</div>
      </div>

      <div class="kflexc">
        <div style="width: 220px; margin-right: 20px; margin-bottom: 20px;">

          <el-select clearable v-model="all.merchant_name"  style="width: 220px;" filterable placeholder="选择分销商">
            <el-option :label="item.name" :value="item.child_shop_id"  v-for="item in fenxiaoshanglists" :key="item.child_shop_id" ></el-option>
          </el-select>
        </div>
        <div style="width: 220px; margin-right: 20px; margin-bottom: 20px;">
          <!-- <el-input v-model="all.cm_name" placeholder="客户经理"></el-input> -->
          <el-select  v-model="all.cm_name" style="width: 220px;" placeholder="选择客户经理" filterable clearable>
            <el-option :label="item.name" :value="item.id"  v-for="item in kehujinglilists" :key="item.id" ></el-option>
          </el-select>
        </div>
        <!-- <div style="width: 250px; margin-right: 20px; margin-bottom: 20px;">
          <el-input v-model="all.status" placeholder="状态"></el-input>
        </div> -->
        <div style=" margin-right: 20px; margin-bottom: 20px;" v-if="all.is_already_pay == 0">
          <el-date-picker v-model="times" @change="timeschange" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']" :clearable="false" type="datetimerange" range-separator="至" start-placeholder="产品导入结果开始日期" end-placeholder="产品导入结果结束日期"></el-date-picker>
        </div>
        <div style=" margin-right: 20px; margin-bottom: 20px;" v-if="all.is_already_pay == 1">
          <el-date-picker v-model="times2" @change="timeschange2" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']" :clearable="false" type="datetimerange" range-separator="至" start-placeholder="结算时间开始日期" end-placeholder="结算时间结束日期"></el-date-picker>

        </div>

        <el-button type="danger" round  style="margin-right: 20px; margin-bottom: 20px;" @click="search()">搜索</el-button>

        <el-button type="danger" round  plain style="margin-right: 20px; margin-bottom: 20px;" @click="daochuall()">导出全部</el-button>


      </div>
      <div class="kflexc">
        <el-button type="danger" round style="margin-right: 20px;" @click="zhichuduo"  v-if="checkquanxian('V020201').length > 0">批量进入支出审核</el-button>
        <el-button type="danger" round style="margin-right: 20px;" @click="piliangzhichu" v-if="all.is_already_pay == 0">批量支出</el-button>
        <!-- <el-button type="danger" round style="margin-right: 20px;"  @click="piliangdaochu">合并导出当前明细</el-button> -->
      </div>
      <div v-if="checkkong(list)" class="kflexcc" style="height: 500px; width: 100%; color: rgb(189, 189, 189);">
        未核算前无结果展示，请先点击“核算当前佣金”按钮
      </div>
      <el-table v-if="!checkkong(list)" :data="list" border style="width: 100%; margin: 20px 0;" ref="multipleTable" @select-all="handleSelectionChange" @selection-change="handleSelectionChange2">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column align='center' prop='merchant_name' label="分销商"></el-table-column>
        <el-table-column align='center' prop='orders_count' label="待核算订单"></el-table-column>
        <el-table-column align='center' prop='satisfied_count' label="满足结算"></el-table-column>
        <el-table-column align='center' prop='unsatisfied_count' label="不满足结算"></el-table-column>
        <el-table-column align='center' prop='sum_commission' label="待核算金额"></el-table-column>
        <el-table-column align='center' prop='adjust_commission' label="扣罚&奖励金额" v-if="all.is_already_pay == 1"></el-table-column>

        <el-table-column align='center' prop='last_paid_at' label="最近一次佣金结算时间" v-if="all.is_already_pay == 0"></el-table-column>

        <el-table-column align='center' prop='confirm_expend_at' label="给分销商结算的时间" v-if="all.is_already_pay == 1"></el-table-column>

        <el-table-column align='center' prop='status_name' label="打款状态"  v-if="all.is_already_pay == 1"></el-table-column>

        <el-table-column align='center' label="撤回状态" >
          <template slot-scope="scope">
            <div class="kflexcc" v-if="scope.row.is_revoke == 0">正常</div>
            <div class="kflexcc" v-if="scope.row.is_revoke == 10">已撤回</div>
          </template>
        </el-table-column>

        <el-table-column align='center' label="操作" width="250px">
          <template slot-scope="scope">


            <div class="kflexcc">
              <div style="color: #409EFF; margin-right: 20px; cursor: pointer;"  @click="xiazai(scope.row)" class="kflexc">
                <el-tooltip class="item" effect="dark" content="本记录中包含粗放结算方式订单，请仔细核实金额" placement="top-start" v-if="scope.row.is_cf == 1 && all.is_already_pay == 0">
                  <img src="https://photo.91haoka.cn/jingtanhao.png" style="cursor: pointer; margin-right: 5px; position: relative; top: -2px; ">
                </el-tooltip>
                下载明细
              </div>

              <div style="color: #409EFF;  cursor: pointer;" v-if="all.is_already_pay == 0 && scope.row.is_revoke != 10" @click="zhichu(scope.row)">确认支出</div>

              <div style="color: rgb(189, 189, 189); " v-if="scope.row.is_revoke == 10">确认支出</div>

              <div style="color: #409EFF;  cursor: pointer;" v-if="(scope.row.status == 10 || scope.row.status == 25) && scope.row.is_revoke != 10" @click="chehui(scope.row)">支出撤回</div>

              <el-tooltip class="item" effect="dark" content="该笔支出当前提现中无法撤回，请联系财务驳回后执行撤回" placement="top-start" v-if="scope.row.status == 20">
              	<span style="color: #f00; font-size: 16px; cursor: pointer; margin-left: 20px;" >
              		<i class="el-icon-warning"></i>
              	</span>
              </el-tooltip>

              <el-tooltip class="item" effect="dark" content="该笔支出当前已打款无法撤回，请联系下游线下处理" placement="top-start" v-if="scope.row.status == 30">
              	<span style="color: #f00; font-size: 16px; cursor: pointer; margin-left: 20px;" >
              		<i class="el-icon-warning"></i>
              	</span>
              </el-tooltip>

            </div>


            <!-- <el-button type="text"  @click="querenzhichugo2(scope.row)"  v-if="scope.row.status == 60 && checkquanxian('V020202').length > 0">审核确认</el-button> -->

          </template>
        </el-table-column>
      </el-table>
      <el-pagination v-if="!checkkong(list)" style="text-align: right;" background layout="total,prev, pager, next" :current-page="all.page" @current-change="fanye" :page-size="all.page_size" :total="total"></el-pagination>
    </div>
    <el-dialog title="佣金确认支出" center :visible.sync="logq" :close-on-click-modal="false" width="1040px">
      <div style="color: rgb(60, 60, 60);font-size: 14px;">
        <div class="kflexc" style="margin-bottom: 10px;">
          <div style="width: 200px; margin-right: 20px; text-align: right;">结算分销商</div>
          <div>{{querenzhichuall.merchant_name}}</div>
        </div>
        <div class="kflexc" style="margin-bottom: 10px;" >
          <div style="width: 200px; margin-right: 20px; text-align: right; ">结算金额</div>
          <div style="color: rgb(255, 79, 0);">￥{{querenzhichuall.sum_commission}}</div>
        </div>
        <div class="kflexc" style="margin-bottom: 10px;" >
          <div style="width: 200px; margin-right: 20px; text-align: right; ">结算订单数</div>
          <div>{{querenzhichuall.orders_count}}</div>
        </div>

        <div class="kflexc" style="margin-bottom: 10px;" >
          <div style="width: 200px; margin-right: 20px; text-align: right; ">
            佣金调整（扣罚/奖励）
          </div>

          <div v-if="!bianjizhong && !querenzhichuall.adjust_commission && !querenzhichuall.adjust_remark" class="kflexc">
            <div style="margin-right: 20px;">无</div>
            <div style="color: rgb(24, 91, 255); cursor: pointer;" @click="bianjizhong = true">+佣金调整（扣罚/奖励）</div>
          </div>
          <div v-if="bianjizhong" style="background: rgb(248, 248, 248); padding: 20px; border: 1px solid rgb(204, 204, 204); width: 600px;" class="baise">
            <div class="kflexc" style="margin-bottom: 10px;" >
              <div style="width: 120px; margin-right: 20px; text-align: right; ">调整方式</div>
              <div>
                <el-select clearable filterable style="width: 250px;" v-model="bianjiall.type" placeholder="调整方式">
                  <el-option  label="奖励"  :value="1"  v-if="punish_only == 0"></el-option>
                  <el-option  label="扣除"  :value="2"></el-option>
                </el-select>
              </div>
            </div>

            <div class="kflexc" style="margin-bottom: 10px;" v-if="bianjiall.type == 1">
              <div style="width: 120px; margin-right: 20px; text-align: right; ">金额</div>
              <div>
                <el-input v-model="bianjiall.adjust_commission" style="width: 250px;" placeholder="金额"></el-input>
              </div>
            </div>
            <div class="kflexc" style="margin-bottom: 10px; padding-left: 80px;" v-if="bianjiall.type == 2">

              <div class="kflexc"  style="margin-bottom: 10px;">
                <el-radio v-model="bianjiall.amount_type" label="0">
                  <div class="kflexc">
                    <div style="margin-right: 20px; text-align: right; ">总金额扣除</div>
                    <div>
                      <el-input v-model="bianjiall.adjust_commission" style="width: 250px;" placeholder="金额"></el-input>
                    </div>
                  </div>
                </el-radio>
              </div>

              <div class="kflexc">
                <el-radio v-model="bianjiall.amount_type" label="1">
                  <div class="kflexc">
                    <div style=" margin-right: 20px;  text-align: right; ">按明细扣除</div>
                    <div>
                      <el-upload ref="upload" action="#" :before-upload="uploasd" :show-file-list="false" accept=".xlsx,.xls">
                         <el-button type="primary" plain small round>导入明细</el-button>
                      </el-upload>
                    </div>
                    <div v-if="bianjiall.details.length>0" style="margin-left: 10px;">已上传数据</div>
                    <div @click="xiazai2" style="margin-left: 10px;">下载模板</div>
                  </div>
                </el-radio>

              </div>
            </div>
            <div class="kflexc" style="margin-bottom: 10px;" >
              <div style="width: 120px; margin-right: 20px; text-align: right; " v-if="bianjiall.type == 2">扣除原因</div>
              <div style="width: 120px; margin-right: 20px; text-align: right; " v-if="bianjiall.type == 1">奖励原因</div>
              <div>
                <el-input v-model="bianjiall.adjust_remark" style="width: 250px;" placeholder="扣除原因" v-if="bianjiall.type == 2"></el-input>
                <el-input v-model="bianjiall.adjust_remark" style="width: 250px;" placeholder="奖励原因" v-if="bianjiall.type == 1"></el-input>
              </div>
            </div>
            <div class="kflex" style="justify-content: end;">
              <el-button round @click="bianjizhong = false">取消</el-button>
              <el-button round type="primary" @click="bianjigo">确定</el-button>
            </div>
          </div>


          <div style="background: rgb(248, 248, 248); position: relative; padding: 20px; border: 1px solid rgb(204, 204, 204);  width: 480px;" v-if="!bianjizhong && (querenzhichuall.adjust_commission || querenzhichuall.adjust_remark)">
            <div style="position: absolute; right: 10px; top: 10px;" >
              <el-button round @click="bianjizhong = true">编辑</el-button>
            </div>
            <div class="kflexc" style="margin-bottom: 10px;" v-if="querenzhichuall.adjust_commission">
              <div style=" margin-right: 20px; text-align: right; " v-if="bianjiall.type == 1">奖励金额</div>
              <div style=" margin-right: 20px; text-align: right; " v-if="bianjiall.type == 2">扣除金额</div>
              <div style="color: rgb(180, 0, 0);">{{querenzhichuall.adjust_commission}}</div>
            </div>
            <div class="kflexc" style="margin-bottom: 10px;"  v-if="querenzhichuall.adjust_remark">
              <div style=" margin-right: 20px; text-align: right; " v-if="bianjiall.type == 1">奖励原因</div>
              <div style=" margin-right: 20px; text-align: right; " v-if="bianjiall.type == 2">扣除金额</div>
              <div style="color: rgb(101, 101, 101);">{{querenzhichuall.adjust_remark}}</div>
            </div>
          </div>
        </div>
        <div class="kflexc" style="margin-bottom: 10px;" >
          <div style="width: 200px; margin-right: 20px; text-align: right; ">最终结算金额</div>
          <div>{{querenzhichuall.zuizhong}}</div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="info" round @click="logq = false">取消</el-button>
        <el-button type="primary" round @click="querenzhichugo">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="错误提示" center :visible.sync="cuowushow" :close-on-click-modal="false" width="1040px">
      <div v-for="(item,index) in cuowu" :key="index">
        {{item}}
      </div>
      <div slot="footer" class="dialog-footer">
       <el-button type="primary" round @click="cuowushow = false">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="选择" :visible.sync="xuanzelog" :close-on-click-modal="false" width="500px">
      <div class="kflexc">
          <el-radio v-model="radio" :label="0">全选本页</el-radio>
          <el-radio v-model="radio" :label="1">全选全部</el-radio>
      </div>
      <div slot="footer" class="dialog-footer">
       <el-button round @click="xuanzelog = false">取消</el-button>
       <el-button type="danger" round @click="xuanzelog = false">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="批量支出确认" :visible.sync="piliangzhichulog" :close-on-click-modal="false" width="500px">
      <div class="kflexc" style="color: rgb(64, 66, 71);">
          请再次点击确认本次支出，批量支出执行可能需要几分钟时间
      </div>
      <div slot="footer" class="dialog-footer">
       <el-button round @click="piliangzhichulog = false">取消</el-button>
       <el-button type="danger" round @click="piliangzhichugo">确定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
  import top2 from './top.vue'
  import axios from 'axios'
  import top from '@/components/top.vue'
  import left from '@/components/left.vue'
  import foot from '@/components/foot.vue'
  import moment from "moment";
  import XLSX from 'xlsx';
  import _ from 'lodash';
  import {
      read,utils
    } from 'xlsx'

  export default {
    components: {
      "left": left,
      "top": top,
      "foot": foot,
      top2
    },
    name: "ke",
    data() {
      return {
        piliangzhichulog:false,
        xuanzelog:false,
        radio:0,
        dangqianxuanzhong2:[],
        loading2:false,
        hesuanshijian:"",
        is_accounting:0,

        dangqianxuanzhong:[],
        bianjizhong:false,
        bianjiall:{
          details:[],
          type:1
        },
        times:[],
        times2:[],
        loading:false,
        list:"",
        all:{
          merchant_name:"",
          cm_name:"",
          page:1,
          page_size:20,
          status:0,
          method_type:1,
          start_time:"",
          end_time:"",
          is_already_pay:0,
          confirm_expend_at_start:"",
          confirm_expend_at_end :""
        },
        total:0,
        kehujinglilists:"",
        fenxiaoshanglists:"",
        logq:false,
        querenzhichuall:{
          adjust_commission:"",
          adjust_remark:""
        },
        punish_only:"",
        peizhi:"",
        cuowushow:false,
        cuowu:[],
        zhichupeizhi:false,
        xunhuan:""
      }
    },
    created() {
      this.getlist()


      if(JSON.parse(localStorage.getItem('USER')).id == JSON.parse(localStorage.getItem('SHOP')).shop_id){
        this.zhichupeizhi = true
      }

      this.xunhuan = setInterval(()=>{
        this.getzhuangtai()
      },5000)


      //获取客户经理
      axios.get('/api/plan-market/user/userManagerList')
        .then(response => {
          if (response.data.msg.code == 0) {
             this.kehujinglilists = response.data.data
          } else {
             this.$message.error(response.data.msg.info);
          }
      })
      //获取全部分销商
      axios.get('/api/gth/partner/list?page_size=2000')
        .then(response => {
          if (response.data.msg.code == 0) {
            this.fenxiaoshanglists = response.data.data.data
          } else {
            this.$message.error(response.data.msg.info);
          }
        })

      // axios.get('/api/plan-market/expend/shopConfigInfo')
      //   .then(response => {
      //     if (response.data.msg.code == 0) {
      //       this.peizhi = response.data.data

      //     } else {
      //       this.$message.error(response.data.msg.info);
      //     }
      // })

    },
    mounted() {

    },
    methods: {
      chehui:function(item){
        axios.post('/api/plan-market/expend/pool/revoke',{id:item.id})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message.success('操作成功');
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      getzhuangtai:function(){
        axios.get('/api/plan-market/expend/commission/calculate/status')
          .then(response => {
            if (response.data.msg.code == 0) {
              this.is_accounting = response.data.data.is_accounting
              if(response.data.data.is_accounting == 0){
                this.loading2 = false
                clearInterval(this.xunhuan)
                this.getlist()
              }
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      // gethesuan:function(){
      //   axios.get('/api/plan-market/expend/pools')
      //   .then(response => {
      //       if (response.data.msg.code == 0) {
      //         this.hesuanshijian = response.data.data.last_settlement_at
      //       } else {
      //         this.$message.error(response.data.msg.info);
      //       }
      //   })
      // },
      hesuandangqian:function(){
        this.loading2 = true
        axios.post('/api/plan-market/expend/pool/calculate/money')
        .then(response => {
            if (response.data.msg.code == 0) {
              this.getzhuangtai()

              this.xunhuan = setInterval(()=>{
                this.getzhuangtai()
              },5000)


            } else {

              this.$message.error(response.data.msg.info);
            }
        })
      },
      piliangzhichu:function(){
        console.log(this.dangqianxuanzhong2)
        if(this.checkkong(this.dangqianxuanzhong2)){
          this.$message.error('请先选择数据');
        }else{
          this.piliangzhichulog = true
        }
      },

      piliangzhichugo:function(){
        axios.post('/api/plan-market/expend/pool/calculate/batch',{
          is_all:this.radio,
          sum_ids:this.dangqianxuanzhong2
        })
        .then(response => {
            if (response.data.msg.code == 0) {
              this.piliangzhichulog = false
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
        })
      },
      changepay:function(val){
        this.all.is_already_pay = val
        this.all.start_time = ""
        this.all.end_time = ""
        this.all.confirm_expend_at_start = ""
        this.all.confirm_expend_at_end = ""
        this.search()
      },
      timeschange:function(){
        if(this.times != null){
          this.all.start_time = this.times[0]
          this.all.end_time = this.times[1]
        }else{
          this.all.start_time = ""
          this.all.end_time = ""
        }
      },
      timeschange2:function(){
        if(this.times2 != null){
          this.all.confirm_expend_at_start = this.times2[0]
          this.all.confirm_expend_at_end = this.times2[1]
        }else{
          this.all.confirm_expend_at_start = ""
          this.all.confirm_expend_at_end = ""
        }
      },
      //导入
      readExcel1(files) {
        return new Promise((res, rej) => {
          var that = this;
          if (files.length <= 0) {
            return;
          }
          if (!/\.(xls|xlsx)$/.test(files[0].name.toLowerCase())) {
            this.$Message.error('上传格式不正确，请上传xls或者xlsx格式');
            return;
          }
          const fileReader = new FileReader();
          fileReader.onload = (ev) => {
            try {
              const data = ev.target.result;
              const workbook = read(data, {
                type: 'binary'
              });
              // 取第一张表
              const wsname = workbook.SheetNames[0];
              // 生成json表格内容
              const ws = utils.sheet_to_json(workbook.Sheets[wsname]);
              console.log(ws);
              // 后续为自己对ws数据的处理
              res(ws)
            } catch (e) {
              return false;
              rej(e)
            }
          };
          fileReader.readAsBinaryString(files[0]);
        })

      },
      uploasd(file, fileList) {
        var that = this
        let files = {
          0: file
        }
        this.bianjiall.details = []
        let arr = []

        let ff = this.readExcel1(files);
        ff.then((res) => {

          res.forEach(item => {
            let obj = {
              order_id: item['订单号'],
              change_commission: item['扣除金额'],
              change_reason: item['扣罚原因'],
            }
            arr.push(obj)
          })
          this.$set( this.bianjiall,'details',arr)

          axios.post('/api/plan-market/expend/pool/verify',{
            id:this.querenzhichuall.id,
            amount_type:1,
            details:arr
          })
          .then(response => {
              if (response.data.msg.code == 0) {

                this.querenzhichuall.zuizhong = parseFloat(this.querenzhichuall.sum_commission)  - parseFloat(response.data.data.adjust_commission)

                this.cuowu = response.data.data.fail_datas
                if(response.data.data.fail_datas.length > 0){
                  this.cuowushow = true
                }
              } else {
                this.$message.error(response.data.msg.info);
              }
          })

        })




      },

      bianjigo:function(){

        this.querenzhichuall.adjust_remark = this.bianjiall.adjust_remark

        if(this.bianjiall.type == 2 && this.bianjiall.adjust_commission > 0){
          this.querenzhichuall.adjust_commission = -this.bianjiall.adjust_commission

          this.querenzhichuall.zuizhong = parseFloat(this.querenzhichuall.sum_commission)  - parseFloat(this.bianjiall.adjust_commission)
        }
        if(this.bianjiall.type == 1 && this.bianjiall.adjust_commission > 0){
          this.querenzhichuall.adjust_commission = Math.abs(this.bianjiall.adjust_commission)

          this.querenzhichuall.zuizhong = parseFloat(this.querenzhichuall.sum_commission)  + parseFloat(this.bianjiall.adjust_commission)
        }



        this.bianjizhong = false
      },

      querenzhichugo2:function(item){
        axios.post('/api/plan-market/expend/pool/second',{
          id:item.id
        })
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message.success('操作成功');
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },

      querenzhichugo:function(){

        this.$confirm('确认支出吗，请务必确保已核算无误?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          axios.post('/api/plan-market/expend/pool',{
            id:this.querenzhichuall.id,
            adjust_commission:this.querenzhichuall.adjust_commission,
            adjust_remark:this.querenzhichuall.adjust_remark,
            details:this.bianjiall.details,
            amount_type:this.bianjiall.amount_type
          })
            .then(response => {
              if (response.data.msg.code == 0) {
                this.$message.success('操作成功');
                this.getlist()
                this.logq = false
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
        })


      },
      zhichuduo:function(){
        axios.post('/api/plan-market/expend/pools',{ids:this.dangqianxuanzhong})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message.success('操作成功');
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      zhichu:function(item){
        this.querenzhichuall = JSON.parse(JSON.stringify(item))
        this.logq = true
      },
      daochuall:function(){

        axios.post('/api/plan-market/expend/pool/expall',this.all)
          .then(response => {
            if (response.data.msg.code == 0) {
              window.open(location.origin +'/gth/#/yongjinzhichu/order_export_yongjinzhichu')
              // this.$router.push('/yongjinzhichu/order_export_yongjinzhichu')

              // location.href =  location.origin + '/' + response.data.data
            } else {
              this.$message.error(response.data.msg.info);
            }
          })

      },
      search: function() {
        this.all.page = 1
        this.getlist()
      },
      //翻页
      fanye: function(page) {
        this.loading = true
        this.all.page = page
        this.getlist()
      },
      //获取列表
      getlist: function() {
        axios.get('/api/plan-market/expend/pools',{params:this.all})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.list = response.data.data.data
              this.hesuanshijian = response.data.data.last_settlement_at
              // this.is_accounting = response.data.data.is_accounting
              if(this.list.length > 0){
                this.list.forEach(item=>{
                  if(item.adjust_commission == 0){
                    item.adjust_commission = ''
                  }
                  if(item.adjust_remark == 0){
                    item.adjust_remark = ''
                  }
                })
              }
              this.total = response.data.data.total
              this.punish_only = response.data.data.punish_only
              if(this.punish_only == 1){
                this.bianjiall.type = 2
              }

              this.loading = false
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },

      //下载
      xiazai: function(item) {
        axios.post('/api/plan-market/expend/pool/exp',{id:item.id})
          .then(response => {
            if (response.data.msg.code == 0) {
              location.href = location.origin + '/' + response.data.data
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      xiazai2:function(){
        location.href = 'https://file.storep.91haoka.cn/gantanhao/daorumingxi2.xlsx'
      },

      handleSelectionChange2:function(val){

        if(val.length > 0){
          let arr = []
          val.forEach(item=>{
            arr.push(item.id)
          })
          this.dangqianxuanzhong2 = arr
        }else{
          this.dangqianxuanzhong2 = []
        }

      },
      handleSelectionChange(val) {

        if(val.length > 0){
          let arr = []
          val.forEach(item=>{
            arr.push(item.id)
          })
          this.dangqianxuanzhong2 = arr
          this.xuanzelog = true
        }else{
          this.dangqianxuanzhong2 = []
        }


        // this.dangqianxuanzhong = []
        // if(val.length > 0){
        //   val.forEach(item=>{
        //     this.dangqianxuanzhong.push(item.id)
        //   })
        // }
      }

    }
  }
</script>

<style lang="scss" scoped>
  .ke {
    /deep/ .el-radio{ display: flex; align-items: center;}

    .lia{ padding:0 0 10px 0; margin: 0 40px 0 0; border-bottom: 3px rgb(255, 255, 255) solid; cursor: pointer; color: rgb(51, 51, 51); font-size: 16px;}

    .acts{ position: relative; color: #2974FF !important; font-weight: bold;
          &::after{
            content: '';
            position: absolute;
            left: 50%;
            bottom: 0;
            margin-left: -15px;
            height: 3px;
            width: 30px; border-radius: 5px;
            background: #2974FF;
          }
    }

    .powertop {
    	display: flex;
    	background:#f9f9f9;
    }
    .powertopli {
    	flex-basis: 180px;
    	line-height: 50px;
    	border-bottom: 3px #F9F9F9 solid;
    	color: #727272;
    	border-right: 1px #F9F9F9 solid;
    	font-size: 16px;
    	text-align: center;
    }
    .router-link-active {
    	background: #FFFFFF;
    	border-bottom: 3px #2974FF solid;
    }
    /deep/ .el-pagination.is-background .btn-prev:disabled{ background: rgba(246, 246, 246, 0.3); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .el-pagination.is-background .btn-next:disabled{ background: rgba(246, 246, 246, 0.3); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .el-pagination.is-background .btn-next{ background: rgba(246, 246, 246,1); border: 1px rgba(167, 167, 167,1) solid;}
    /deep/ .el-pagination.is-background .btn-prev{ background: rgba(246, 246, 246,1); border: 1px rgba(167, 167, 167,1) solid;}
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active{ background-color: #2974FF;}
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
        color: #fff;
    }
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
        color: #2974FF;
    }
    /deep/ .el-pager li{ border-radius: 14px; background: rgba(255, 255, 255, 1); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .btn-prev{ border-radius: 14px; padding: 0 10px;}
    /deep/ .btn-next{ border-radius: 14px; padding: 0 10px;}

    /deep/ .el-table th{ background: rgb(246, 246, 246);}
    /deep/ .el-input__inner{ line-height: 36px; height: 36px; font-size: 12px; background: rgb(247, 248, 250);  border: 0;}
    /deep/ .el-date-editor .el-range-input{ background: rgb(247, 248, 250); }
    /deep/ .el-button{ padding: 11px 23px !important;}
    /deep/ .el-button--mini{ padding: 6px 15px !important;}
    /deep/ .el-button--danger {
        color: #FFF;
        background-color: #2974FF;
        border-color: #2974FF;
    }
    .team {
    	background: #F9F9F9;
    }
    /deep/ .baise .el-input__inner{ line-height: 36px; height: 36px; font-size: 12px; background: rgb(255,255,255);  border: 0;}
  }
</style>
